--- created: source_filename: /home/runner/work/mknodes/mknodes/mknodes/pages/mkclasspage/__init__.py source_function: MkClassPage.__init__ source_line_no: 46 hide: - toc icon: material/dev-to status: new template: SUMMARY.html title: MkDevEnvSetup --- [:fa-brands-github: Show source on GitHub](https://github.com/phil65/mknodes/blob/main/mknodes/templatenodes/mkdevenvsetup/__init__.py) ### Text node containing Instructions to set up a dev environment. === "Examples" ### Example: **From project** !!! jinja "Jinja" ``` {.jinja } {{ mk.MkDevEnvSetup() }} ``` !!! python "Python" ``` {.python } MkDevEnvSetup() ``` ===! "Rendered" All development for this library happens in the [mknodes](https://github.com/phil65/mknodes.git) repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package: ```` {.md } # Clone the repository git clone https://github.com/phil65/mknodes.git cd mknodes ```` ## Build system Hatch is used as the build system. ```` {.bash } pip install hatch ```` [More information](https://hatch.pypa.io) === "Markdown" ``` {.markdown } All development for this library happens in the [mknodes](https://github.com/phil65/mknodes.git) repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package: ```` {.md } # Clone the repository git clone https://github.com/phil65/mknodes.git cd mknodes ```` ## Build system Hatch is used as the build system. ```` {.bash } pip install hatch ```` [More information](https://hatch.pypa.io) ``` === "Html" ``` {.html }

All development for this library happens in the .git.md repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package:

# Clone the repository
        git clone .git
        cd 
        

Build system

Hatch is used as the build system.

pip install hatch
        

More information

``` === "Repr tree" ``` MkDevEnvSetup ├── MkLink('https://github.com/phil65/mknodes.git', 'mknodes') ├── MkCode('# Clone the repository\ngit clone https://github.com/phil65/mknodes.git\ncd mknodes', language='md') │ ╰── MkText('# Clone the repository\ngit clone https://github.com/phil65/mknodes.git\ncd mknodes') ├── MkHeader('Build system') ├── MkCode('pip install hatch', language='bash') │ ╰── MkText('pip install hatch') ╰── MkLink('https://hatch.pypa.io', 'More information') ``` ### Example: **Explicit** !!! jinja "Jinja" ``` {.jinja } {{ mk.MkDevEnvSetup(repo_url="http://url_to_git_repo.com/name.git") }} ``` !!! python "Python" ``` {.python } MkDevEnvSetup(repo_url='http://url_to_git_repo.com/name.git') ``` ===! "Rendered" All development for this library happens in the [name](http://url_to_git_repo.com/name.git) repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package: ```` {.md } # Clone the repository git clone http://url_to_git_repo.com/name.git cd name ```` ## Build system Hatch is used as the build system. ```` {.bash } pip install hatch ```` [More information](https://hatch.pypa.io) === "Markdown" ``` {.markdown } All development for this library happens in the [name](http://url_to_git_repo.com/name.git) repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package: ```` {.md } # Clone the repository git clone http://url_to_git_repo.com/name.git cd name ```` ## Build system Hatch is used as the build system. ```` {.bash } pip install hatch ```` [More information](https://hatch.pypa.io) ``` === "Html" ``` {.html }

All development for this library happens in the name repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package:

# Clone the repository
        git clone http://url_to_git_repo.com/name.git
        cd name
        

Build system

Hatch is used as the build system.

pip install hatch
        

More information

``` === "Repr tree" ``` MkDevEnvSetup ├── MkLink('http://url_to_git_repo.com/name.git', 'name') ├── MkCode('# Clone the repository\ngit clone http://url_to_git_repo.com/name.git\ncd name', language='md') │ ╰── MkText('# Clone the repository\ngit clone http://url_to_git_repo.com/name.git\ncd name') ├── MkHeader('Build system') ├── MkCode('pip install hatch', language='bash') │ ╰── MkText('pip install hatch') ╰── MkLink('https://hatch.pypa.io', 'More information') ``` === "DocStrings" ::: mknodes.MkDevEnvSetup options: show_docstring_description: False === "Base classes" | Name | Children | Inherits | |--- | --- | --- | | **[MkTemplate](https://phil65.github.io/mknodes/)**
*mknodes.templatenodes.mktemplate*
Node representing a jinja template\. | | | === "⋔ Inheritance diagram" ``` mermaid graph TD 94721312203728["mkdevenvsetup.MkDevEnvSetup"] 94721308869584["mktemplate.MkTemplate"] 94721311697232["mkcontainer.MkContainer"] 94721308848336["mknode.MkNode"] 94721311766592["node.Node"] 140564252373184["builtins.object"] 94721308869584 --> 94721312203728 94721311697232 --> 94721308869584 94721308848336 --> 94721311697232 94721311766592 --> 94721308848336 140564252373184 --> 94721311766592 ``` === "NodeFile" ``` {.toml title='/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkdevenvsetup/metadata.toml'} [metadata] icon = "mdi:dev-to" status = "new" name = "MkDevEnvSetup" virtual_children = true [examples.regular] title = "From project" jinja = """ {{ mk.MkDevEnvSetup() }} """ [examples.explicit] title = "Explicit" jinja = """ {{ mk.MkDevEnvSetup(repo_url="http://url_to_git_repo.com/name.git") }} """ [output.markdown] template = """ {% set folder_name = node.repo_url.removesuffix(".git").split("/")[-1] %} All development for this library happens in the {{ node.repo_url | MkLink(folder_name) }} repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package: {{ ("# Clone the repository git clone " ~ node.repo_url ~ " cd " ~ folder_name ) | MkCode(language="md") }} {{ "Build system" | MkHeader }} {{ node.build_backend.identifier.capitalize() }} is used as the build system. {{ ("pip install " ~ node.build_backend.identifier) | MkCode(language="bash") }} {{ node.build_backend.url | MkLink("More information")}} """ ``` === "Code" ``` {.python title='mknodes.templatenodes.mkdevenvsetup.MkDevEnvSetup' linenums='9'} class MkDevEnvSetup(mktemplate.MkTemplate): """Text node containing Instructions to set up a dev environment.""" ICON = "material/dev-to" def __init__( self, *, repo_url: str | None = None, build_backend: buildsystems.BuildSystemStr | None = None, **kwargs: Any, ): """Constructor. Args: repo_url: Repo url to show. If None, it will be pulled from project. build_backend: Build backend to show install instructions for. If None, it will be pulled from project. kwargs: Keyword arguments passed to parent """ super().__init__("output/markdown/template", **kwargs) self._repo_url: str | None = repo_url self._build_backend: buildsystems.BuildSystemStr | None = build_backend @property def repo_url(self) -> str: match self._repo_url: case None: repo_url = self.ctx.metadata.repository_url case str(): repo_url = self._repo_url case _: raise TypeError(self._repo_url) repo_url = repo_url.rstrip("/") if not repo_url.endswith(".git"): repo_url += ".git" return repo_url @repo_url.setter def repo_url(self, value): self._repo_url = value @property def build_backend(self) -> buildsystems.BuildSystem: # type: ignore[return] if self._build_backend is None: return self.ctx.metadata.build_system or buildsystems.setuptools return buildsystems.BUILD_SYSTEMS[self._build_backend] @build_backend.setter def build_backend(self, value): self._build_backend = value ```